package com.factors.ZhangDingHou.Parenral_Involvement;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class ParentalInvolvementStatsMapper extends Mapper<LongWritable, Text, Text, DoubleWritable> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {


        String[] columns = value.toString().split(",");
        if (columns.length >= 20) {
            try {
                String parentalInvolvement = columns[2];
                double examScore = Double.parseDouble(columns[19]);


                context.write(new Text(parentalInvolvement), new DoubleWritable(examScore));
            } catch (Exception e) {

            }
        }
    }
}